export const dateRangeOptions = {
  shortcuts: [
    {
      text: "今日",
      value: () => {
        const end = new Date(new Date().setHours(23, 59, 59, 0));
        const start = new Date(new Date().setHours(0, 0, 0, 0));
        return [start, end]
      }
    },
    {
      text: "昨日",
      value: () => {
        const start = new Date();
        start.setTime(start.getTime() - 24 * 60 * 60 * 1000);
        start.setHours(0, 0, 0, 0);
        const end = new Date();
        end.setTime(end.getTime() - 24 * 60 * 60 * 1000);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "本周",
      value: () => {
        const end = new Date();
        const week = end.getDay();
        // 一天的毫秒数
        const millisecond = 1000 * 60 * 60 * 24;
        // 减去的天数
        const minusDay = week !== 0 ? week - 1 : 6;
        // 本周 周一
        const monday = new Date(end.getTime() - minusDay * millisecond);
        const start = new Date(monday);
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "上周",
      value: () => {
        // 上周开始时间
        const starta = new Date();
        const first = starta.getDate() - starta.getDay() - 6;
        const startDate = new Date(starta.setDate(first));
        const start = new Date(startDate);
        start.setHours(0, 0, 0, 0);
        //  上周结束时间
        const currentDate = new Date();
        const firsts = currentDate.getDate() - currentDate.getDay() - 6;
        const last = firsts + 6;
        const endDate = new Date(currentDate.setDate(last));
        const end = new Date(endDate);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "本月",
      value: () => {
        const currentDate = new Date();
        const currentMonth = currentDate.getMonth();
        // 获得当前年份4位年
        const currentYear = currentDate.getFullYear();
        // 求出本月第一天
        const start = new Date(currentYear, currentMonth, 1);
        const end = new Date();
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "上月",
      value: () => {
        // const that = this
        // 获取当前时间
        const currentDate = new Date();
        // 获得当前月份0-11
        let currentMonth = currentDate.getMonth();
        // 获得当前年份4位年
        let currentYear = currentDate.getFullYear();
        // 获得上一个月的第一天
        if (currentMonth === 0) {
          currentMonth = 11; // 月份为上年的最后月份
          currentYear--; // 年份减1
          return new Date(currentYear, currentMonth, 1);
        } else {
          // 否则,只减去月份
          currentMonth--;
        }

        const start = new Date(currentYear, currentMonth, 1);
        start.setHours(0, 0, 0, 0);
        // 获取当前时间
        const currentDates = new Date();
        // 获得当前月份0-11
        let currentMonths = currentDates.getMonth();
        // 获得当前年份4位年
        // let currentYears = currentDates.getFullYear()

        // 当为12月的时候年份需要加1
        // 月份需要更新为0 也就是下一年的第一个月
        if (currentMonths === 11) {
          // currentYears = currentYears + 1
          currentMonths = 0; // 就为
        } else {
          // 否则只是月份增加,以便求的下一月的第一天
          currentMonths++;
        }

        // 一天的毫秒数
        const millisecond = 1000 * 60 * 60 * 24;
        // 求出上月的最后一天
        const aa = new Date();
        const thisMonth = aa.getMonth();
        // 获得当前年份4位年
        const thisYear = aa.getFullYear();
        // 求出本月第一天
        const firstDay = new Date(thisYear, thisMonth, 1);
        const lastDay = new Date(firstDay.getTime() - millisecond);
        const end = new Date(lastDay);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "本年",
      value: () => {
        // 获取当前时间
        const currentDate = new Date();
        // 获得当前年份4位年
        const currentYear = currentDate.getFullYear();

        // 本年第一天
        const start = new Date(currentYear, 0, 1);
        // 本年最后一天
        const end = new Date(currentYear, 11, 31);
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "上年",
      value: () => {
        // 获取当前时间
        const currentDate = new Date();
        // 获得当前年份4位年
        const currentYear = currentDate.getFullYear() - 1;
        // 本年第一天
        const start = new Date(currentYear, 0, 1);
        // 本年最后一天
        const end = new Date(currentYear, 11, 31);
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "1季度",
      value: () => {
        // 获取当前时间
        const currentDate = new Date();
        // 获得当前年份4位年
        const currentYear = currentDate.getFullYear();

        // 第一季度第一天
        const start = new Date(currentYear, 0, 1);
        // 第一季度最后一天
        const end = new Date(currentYear, 2, 31);
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "2季度",
      value: () => {
        // 获取当前时间
        const currentDate = new Date();
        // 获得当前年份4位年
        const currentYear = currentDate.getFullYear();
        // 第一季度第一天
        const start = new Date(currentYear, 3, 1);
        // 第一季度最后一天
        const end = new Date(currentYear, 5, 30);
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "3季度",
      value: () => {
        // 获取当前时间
        const currentDate = new Date();
        // 获得当前年份4位年
        const currentYear = currentDate.getFullYear();
        const start = new Date(currentYear, 6, 1);
        const end = new Date(currentYear, 8, 30);
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
    {
      text: "4季度",
      value: () => {
        // 获取当前时间
        const currentDate = new Date();
        // 获得当前年份4位年
        const currentYear = currentDate.getFullYear();
        const start = new Date(currentYear, 9, 1);
        const end = new Date(currentYear, 11, 31);
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 0);
        return [start, end]
      },
    },
  ],
};
